#include <log4cpp/Category.hh>
#include <log4cpp/Appender.hh>
#include <log4cpp/OstreamAppender.hh>
#include <log4cpp/Layout.hh>
#include <log4cpp/BasicLayout.hh>

int main() {
    // 1. 初始化日志系统
    log4cpp::Appender *appender = new log4cpp::OstreamAppender("console", &std::cout);
    appender->setLayout(new log4cpp::BasicLayout());

    // 2. 获取日志 Category 并添加 Appender
    log4cpp::Category& root = log4cpp::Category::getRoot();
    root.setPriority(log4cpp::Priority::DEBUG);
    root.addAppender(appender);

    // 3. 输出日志
    root.error("Hello, Log4cpp is working!");
    root.warn("This is a warning message");

    // 4. 清理
    log4cpp::Category::shutdown();
    return 0;
}
